<?php

declare(strict_types=1);
/**
 * This file is part of MineAdmin.
 *
 * @link     https://www.mineadmin.com
 * @document https://doc.mineadmin.com
 * @contact  root@imoi.cn
 * @license  https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
 */

namespace App\Http\Admin\Request\Word;

use App\Schema\Word\WordSchema;
use Hyperf\Validation\Request\FormRequest;
use Mine\Swagger\Attributes\FormRequest as FormRequestAnnotation;

#[FormRequestAnnotation(
    schema: WordSchema::class,
    title: '创建单词',
    required: [
        'name',
        'description'
    ],
    only: [
        'name',
        'description'
    ]
)]
class WordRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'word' => 'required|string',
            'interpretation' => 'required|string',
            'origin_word' => 'required|string',
            'phonetic_alphabet' => 'required',
            'group_id' => 'required',
            'audio' => 'required'
        ];
    }

    public function attributes(): array
    {
        return [
            'word' => trans('word.word'),
            'interpretation' => trans('word.interpretation'),
            'origin_word' => trans('word.origin_word'),
            'phonetic_alphabet' => trans('word.phonetic_alphabet'),
            'group_id' => trans('word.group_id'),
            'audio' => trans('word.audio'),
        ];
    }
}
